#ifndef MYTABLEMODEL_H
#define MYTABLEMODEL_H
//拖拽表头互换位置，index怎么对应上?
//答：动的只是显示顺序，索引不会变
#include <QAbstractTableModel>
enum eFileType
{
    e_word = 1000,
    e_excel,
};

struct stFileInfo
{
    bool        m_bChecked;
    QString     fileName;
    QString     owner;
    QString     location;
    QString     modifytime;
    QString     filesize;
    eFileType   efiletype;
};

class MytableModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    explicit MytableModel(QObject *parent = nullptr);

    // Header:
    QVariant headerData(int section,
                        Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const override;

    // Basic functionality:
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    bool setdata(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);

    // Add data:
    bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;

    // Remove data:
    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
    void addData(stFileInfo* fileinfo);
private:
    QList<stFileInfo*> m_data;
};

#endif // MYTABLEMODEL_H
